import { NATIVE_CLASS } from "@common/constants";
import { asyncCallNativeFunc } from "@common/saga-helper";
import {
  SET_FRM_PALLET_LIST,
  SET_FRM_PALLET_ORDER_LINES,
  SET_FRM_PALLET_ORDER_LIST,
} from "./action-types";

export const loadFrmPalletList = async (params) => {
  await asyncCallNativeFunc({
    effects: [
      {
        payload: {
          classFullName: NATIVE_CLASS.FrmPalletHandler,
          action: "loadScrollData",
          needNonce: false,
          params,
        },
        respActions: [SET_FRM_PALLET_LIST],
        callback: params.callback,
      },
    ],
  });
};

export const loadFrmPalletOrderList = async (params) => {
  await asyncCallNativeFunc({
    effects: [
      {
        payload: {
          classFullName: NATIVE_CLASS.FrmPalletHandler,
          action: "loadOrderData",
          needNonce: false,
          params,
        },
        respActions: [SET_FRM_PALLET_ORDER_LIST],
        callback: params.callback,
      },
    ],
  });
};

export const loadFrmPalletOrderLines = async (params) => {
  await asyncCallNativeFunc({
    effects: [
      {
        payload: {
          classFullName: NATIVE_CLASS.FrmPalletHandler,
          action: "loadOrderDetailsData",
          needNonce: false,
          params,
        },
        respActions: [SET_FRM_PALLET_ORDER_LINES],
        callback: params.callback,
      },
    ],
  });
};
